const markdown = require('markdown-it')
const hljs = require('highlight.js') 


function transferMarkdown (source) {

  var md = markdown({
    html: true,
    linkify: true,
    typographer: true,
    highlight: function (str, lang) {
      if (lang && hljs.getLanguage(lang)) {
        try {
          return hljs.highlight(str,{ language: lang }).value;
        } catch (__) {}
      }
  
      return ''; // 使用额外的默认转义
    }
  });

  
  return `<div class='markdown-here-wrapper'>${md.render(source)}</div>`
}

module.exports = transferMarkdown;
